package com.zyh.day02.keyvalue

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object LeftOuterJoinTest {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setAppName("m")
      .setMaster("local[*]")
    val sc = new SparkContext(conf)
    val rdd1: RDD[(String, Int)] = sc.makeRDD(List(("xps15 9570", 57), ("Thinkpad X230", 257), ("联想拯救者R9000", 575), ("iphoneX", 537), ("macMini", 157)))
    val rdd2: RDD[(String, Int)] = sc.makeRDD(List(("Thinkpad X230", 20), ("macMini", 50), ("联想拯救者R9000", 30), ("iphoneX", 40)))

    val result: RDD[(String, (Int, Option[Int]))] = rdd1.leftOuterJoin(rdd2)
    result.foreach(println)
    sc.stop()
  }
}
